package com.lch.distributed.serialize;

import com.alibaba.fastjson.JSON;

/**
 * @author: liuchenhui
 * @create: 2019-06-02 21:24
 **/
public class FastJsonSerializer implements ISerializer {

    @Override
    public <T> byte[] writeObject(T obj) {
        return JSON.toJSONString(obj).getBytes();
    }

    @Override
    public <T> T readObject(byte[] data, Class<T> clazz) {
        return JSON.parseObject(new String(data), clazz);
    }
}
